﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace FaceDesktopTagger
{
    //A class that search for files with specific exntesion wither in Windows Index or given directory
    class SearchFiles
    {
        //TODO : Add try/catch blocks
        public static List<String> Search(String i_path = null, String i_extension = "*") 
        {
            List<string> fileNames = new List<string>();
            if (i_path == null)
            {
                return WSSQL.ExecuteQuery("SELECT System.ItemURL FROM SystemIndex where System.FileExtension='"+ i_extension +"'", 10000000);
            }
            else
            {
                string[] fileEntries = Directory.GetFiles(i_path, "*" + i_extension);
                foreach (string fileName in fileEntries)
                {
                    fileNames.Add(fileName);
                }
                return fileNames;
            }
        }
    
    }
}
